/*
 * parser_factory.cpp
 *
 *  Created on: 09/12/2013
 *      Author: Paulo Fernandes
 */

#include <iostream>
#include <list>
#include "station_info.h"
#include "parser.h"
#include "parser_factory.h"
#include "station_info.h"
#include "hs01.h"
#include "hs02.h"
#include "m02.h"

ParserFactory::ParserFactory() {
    this->list_station.push_back(Station_Info(0, "EH HS01", "HS_01"));
    this->list_station.push_back(Station_Info(1, "EH HS02", "HS02"));
    this->list_station.push_back(Station_Info(2, "EH M02", "EHM02"));
}

ParserFactory::~ParserFactory() {
    //delete(this->list_station);
}

QList<Station_Info>& ParserFactory::get_list_station() {
	return this->list_station;
}

Parser* ParserFactory::select_station(QString filename) {
    int station_number=-1;

    for (int i=0; i<list_station.length() ;i++) {
        Station_Info info = list_station.at(i);
        QString baseName = info.get_base_name();

        if (filename.indexOf(baseName) != -1)
            station_number=i;
    }

	switch (station_number) {
		case 0:
        cout << "HS01" << endl;
            return new Hs01();
            break;
		case 1:
        cout << "HS02" << endl;
            return new Hs02();
            break;
		case 2:
        cout << "M2" << endl;
            return new M02();
        break;

	}
    cout << "Error: station not found";
    exit(1);
}
